<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout/default::defaultHeader('字典管理')"></head>
<body class="hold-transition ">
    <div class="wrapper">
    <div class="main-content">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa icon-social-dropbox"></i> 字典管理
                </div>
                <div class="box-tools pull-right">
                    <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
                    <a href="/js/a/sys/dictType/form" class="btn btn-default btnTool" title="新增字典类型"><i
                            class="fa fa-plus"></i> 新增</a>
                </div>
            </div>
            <div class="box-body">
                <form id="searchForm" action="/a/sys/dict/listData" method="post" class="form-inline ">
                    <input type="hidden" id="pageNo" name="pageNo" value="">
                    <input type="hidden" id="pageSize" name="pageSize" value="">
                    <div class="form-group">
                        <label class="control-label">字典名称：</label>
                        <div class="control-inline">
                            <input type="text" id="label" name="label" value="" maxlength="100"
                                   class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">字典类型：</label>
                        <div class="control-inline" style="width: 150px">
                            <select  name="type" class="form-control" style="width: 500px" >
                                <option value="">--请选择--</option>
                                <option th:each="t:${typeList}" th:value="${t}" th:text="${t}" ></option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-sm">查询</button>
                        <button type="reset" class="btn btn-default btn-sm">重置</button>
                    </div>
                </form>
                <table id="dataGrid"></table>
                <div id="dataGridPage"></div>
            </div>
        </div>
    </div>
</div>
    <footer th:include="layout/default::defaultFooter"></footer>
    <script th:inline="javascript">

        // 初始化DataGrid对象
        $('#dataGrid').dataGrid({
            searchForm: $("#searchForm"),
            editor:true,
            columnModel: [
                {
                    header: '字典名称',
                    name: 'label',
                    index: 'a.label',
                    width: 200,
                    align: "left",
                    frozen: true,
                    editable: true, edittype: 'text'/*,
                formatter: function (val, obj, row, act) {
                    return '<a href="/a/sys/dictType/form?id=' + row.id + '" class="btnList" data-title="编辑字典类型">' + (val || row.id) + '</a>';
                }*/
                },
                {
                    header: '字典类型',
                    name: 'type',
                    index: 'a.type',
                    width: 200,
                    align: "left",
                    frozen: true
                },
                {
                    header: '值',
                    name: 'value',
                    index: 'a.value',
                    width: 200,
                    align: "left",
                    frozen: true
                },
                {
                    header: '描述',
                    name: 'description',
                    index: 'a.description',
                    width: 80,
                    align: "center"
                },
                {
                    header: '更新时间', name: 'updateDate', index: 'a.update_date', width: 150, align: "center"//,
                    , formatter: 'date', formatoptions: {srcformat: 'Y-m-d h:i:s', newformat: 'Y-m-d H:i:s'}
                },
                {header: '备注信息', name: 'remarks', index: 'a.remarks', width: 200, align: "left"},
                {
                    header: '操作',
                    name: 'actions',
                    width: 130,
                    sortable: false,
                    title: false,
                    formatter: function (val, obj, row, act) {
                        var actions = [];
                        actions.push('<a href="/a/sys/dict/form?id=' + row.id + '" class="btnList" title="编辑字典类型"><i class="fa fa-pencil"></i></a>&nbsp;');
                        actions.push('<a href="/a/sys/dict/list?dictType=' + row.dictType + '" class="btnList" title="字典数据"><i class="fa fa-navicon"></i></a>&nbsp;');
                        if (row.status == Global.STATUS_NORMAL) {
                            actions.push('<a href="/a/sys/dict/disable?id=' + row.id + '" class="btnList" title="停用字典类型" data-confirm="确认要停用该字典类型吗？"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
                        }
                        if (row.status == Global.STATUS_DISABLE) {
                            actions.push('<a href="/a/sys/dict/enable?id=' + row.id + '" class="btnList" title="启用字典类型" data-confirm="确认要启用该字典类型吗？"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
                        }
                        actions.push('<a href="/a/sys/dict/delete?id=' + row.id + '" class="btnList" title="删除字典类型" data-confirm="确认要删除该字典类型吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
                        return actions.join('');
                    }
                }
            ],

            // 加载成功后执行事件
            ajaxSuccess: function (data) {
                console.log(data);
                $("#pageNo").val(data.pageNo);
                $("#pageSize").val(data.pageSize);
            }
        });
    </script>
</body>
</html>